<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require('../db_conn.php');

$rec=isset($_GET['rec'])?$_GET['rec']:"";
if ($rec=='insert')
{
    $imgname=$_POST['imgname'];
    $linkurl=$_POST['linkurl'];
    $isshow=$_POST['isshow'];
    $sql="insert into tb_ad(imgname,linkurl,isshow) values('$imgname','$linkurl',$isshow)";
    $rs=$db->query($sql);
    if ($rs==FALSE)
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('添加失败！');";
        echo "window.location.href='show.php'";
        echo "</script>";
    }
}

$sql="SELECT * FROM tb_ad ORDER BY id desc limit 0,5";
$ggs=$db->query($sql); 
$gg1s=$ggs->fetch_all(MYSQLI_BOTH);

require 'show_index.php';

$ggs->free();
$db->close();
